//
//  HomeVC.swift
//  ShareUmbrella
//
//  Created by niupark on 2017/8/5.
//  Copyright © 2017年 尧尚信息科技. All rights reserved.
//

import UIKit
import YSKit
import SWRevealViewController



class HomeVC: YSBaseViewController, MAMapViewDelegate {
    
    override func setup() {
        super.setup()

    }
    
    private func makeBarIconButton(image: UIImage?, title: String?, target: AnyObject?, action: Selector) -> UIBarButtonItem {
    
        let button = UIButton(type: UIButtonType.system).ys.customize { (view) in
            
            view.setImage(image, for: .normal)
            view.titleLabel?.font = YSFont.t05.font
            view.frame = CGRect(x: 15, y: 12, width: 50, height: 20)
            view.addTarget(target, action: action, for: .touchUpInside)
            view.ys.handleTheme { [weak view] in
                
                guard let view = view else {
                    return
                }
                view.setTitle(title, for: .normal)
            }
            
        }
        
        return UIBarButtonItem(customView: button)
    }
    
    /*
     *
     * 界面布局初始化
     */
    override func buildUI() {
        super.buildUI()
        self.title = I18n("VC.home.title")
        let revealController = self.revealViewController()!
        self.view.addGestureRecognizer(revealController.panGestureRecognizer())
        
        self.navigationItem.leftBarButtonItems = YSUI.UIManager.makeBarButtonItems([
            self.makeBarIconButton(image: nil, title: "左边", target: self, action: #selector(actionLeft))
            ])
        
        
        MAMapView(frame: self.view.bounds).ys.customize { (view) in
            self.view.addSubview(view)
            view.delegate = self

            ///如果您需要进入地图就显示定位小蓝点，则需要下面两行代码
            view.showsUserLocation = true
            view.userTrackingMode = .follow

        }
        
        
    }
    
    func actionLeft() {
        //显示左边
        let revealController = self.revealViewController()!
        revealController.revealToggle(nil)
    }

    
    //
    override func buildRx() {
        super.buildRx()
    }
}
